package ui.component
{
	import flash.text.TextField;
	import flash.text.TextFieldType;
	import flash.text.TextFormat;
	
	import flashx.textLayout.formats.TextAlign;
	
	public class TextInput extends TextField
	{
		public static const TYPE_ABC:String = "A-Za-z";//只允许输入字母
		public static const TYPE_ABC123:String = "A-Za-z0-9";//只允许输入字母和数字
		public static const TYPE_ABC123_HANZI:String = "A-Za-z0-9\u4e00-\u9fa5";//只允许输入字母，数字和汉字
		
		private var _format:TextFormat;
		private var _color:uint;
		
		public function get color():uint
		{
			return _color;
		}
		public function set color(value:uint):void
		{
			_color = value;
			this.textColor = _color;
		}
		
		public function TextInput(size:Number,width:uint,height:uint,maxChar:uint,asPassword:Boolean=false,type:String = TYPE_ABC123_HANZI)
		{
			_format = new TextFormat("Verdada");
			_format.size = size;
			_format.align = TextAlign.CENTER;
			_format.letterSpacing = 2;
			defaultTextFormat = _format;
			
			this.restrict = type;
			this.displayAsPassword = asPassword;
			this.width = width;
			this.height= height;
			this.type = TextFieldType.INPUT;
			this.maxChars = maxChar;
			this.textColor = 0xffffff;
		}
	}
}